﻿@model ConferenceModel

@{
    ViewBag.Title = "Register";
}


@if (Model.Conference == null)
{
    <h2>Conference not found</h2>
    return;
}
else if (Model.IsPublicClosed && !Request.IsAuthenticated || Model.IsPrivateClosed) // conference is full because no seats were found!
{
    <h2>Conference registration is closed</h2>
    return;
}

    @Html.Partial("_Conference", Model.Conference)

    <h1>Registration <span>Form</span></h1>
    
    @if (Model.IsPublicClosed) { <p>Registrations are closed to the public.</p> }
    @using (Html.BeginForm())
    {
        @Html.ValidationSummary(true)

        @Html.HiddenFor(model => model.Conference.ID)
        @Html.HiddenFor(model => model.SeatID)
    
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.FirstName)
            @Html.ValidationMessageFor(model => model.Register.FirstName)
            @Html.EditorFor(model => model.Register.LastName)
            @Html.ValidationMessageFor(model => model.Register.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.Email)
            @Html.ValidationMessageFor(model => model.Register.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.Street)
            @Html.ValidationMessageFor(model => model.Register.Street)
            @Html.EditorFor(model => model.Register.Landmark)
            @Html.ValidationMessageFor(model => model.Register.Landmark)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.City)
            @Html.ValidationMessageFor(model => model.Register.City)
            @Html.EditorFor(model => model.Register.State)
            @Html.ValidationMessageFor(model => model.Register.State)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.Country)
            @Html.ValidationMessageFor(model => model.Register.Country)
            @Html.EditorFor(model => model.Register.Zip)
            @Html.ValidationMessageFor(model => model.Register.Zip)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.MobilePhone)
            @Html.ValidationMessageFor(model => model.Register.MobilePhone)
            @Html.EditorFor(model => model.Register.ResidentPhone)
            @Html.ValidationMessageFor(model => model.Register.ResidentPhone)
        </div>      
        <div>
            <span class="back">You must include your country phone code.</span>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.Church)
            @Html.ValidationMessageFor(model => model.Register.Church)
        </div>      
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.IsPastor)
            @Html.ValidationMessageFor(model => model.Register.IsPastor)
            @Html.LabelFor(model => model.Register.IsPastor, "Are you a pastor?")
        </div>
        <br />      
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Register.PaymentType, new SelectList(new string[] {"Cheque", "DD", "Cash"}), "Select a payment type" )
            @Html.ValidationMessageFor(model => model.Register.PaymentType)
            @Html.EditorFor(model => model.Register.PaymentNumber)
            @Html.ValidationMessageFor(model => model.Register.PaymentNumber)<br />
            Please make <span class="light">@Model.Conference.Cost.ToString("0")</span> rupees out to <span class="light">Kingdom Foundations</span>.
            <br />
            Mail payment to our office (below).
        </div>
        <br />
        <div class="editor-field">
            @Html.EditorFor(model => model.Register.IsLocalPickup)
            @Html.ValidationMessageFor(model => model.Register.IsLocalPickup)
            @Html.LabelFor(model => model.Register.IsLocalPickup, "Pickup registration bracelet at our local office?")
        </div>    
        <br />
        <p>
            <h2>Special Individual Ministry Times</h2>
            During this event, various ministry opportunities will be made available.  An international ministry team will be available to provide prayer for healing, prophetic words, and dream interpretation.  These times are intended to refresh, encourage, and bring clarity to participants.
            <ul>
                <li><span class="light">Prophetic Rooms:</span>  Designed for those who are in need of encouragement and clarity, this room is intended to be a place where God’s word for your life comes alive.</li>
                <li><span class="light">Healing Rooms:</span>  Available to all of those who are in need of physical healing, this room is a place where others will contend for your physical restoration and health.</li>
                <li><span class="light">Dream Interpretation Rooms:</span>  Come prepared with a dream you don’t understand and our interpreters will walk you through it’s meaning.</li>
            </ul>
            Slots are limited and participants are only allowed visitation of one room. Be first to register to ensure you are able to utilize this valuable resource.
        </p>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.MinistryID, new SelectList(Model.Ministries, "ID", "Name"), "Select a ministry (optional)")
            @Html.ValidationMessageFor(model => model.MinistryID)
        </div>
        <br />
        <div>
            <input type="submit" value="Register for @Model.SeatName Seat" /> 
            <br />
            <span class="back">Registration is not complete until payment is received.</span>
        </div>
    }

    
    <h1>Seat <span>Information</span></h1>
    @if (Request.IsAuthenticated || (bool.Parse(ConfigurationManager.AppSettings["ShowSeatCount"])))
    {
        <table>
            <tr>
                <td>Seats Filled</td>
                <td><span class="light">@Model.Seats.Sum(e => e.ActualSeats)</span></td>
            </tr>
            <tr>
                <td>Seats Remaining</td>
                <td><span class="light">@Model.Seats.Sum(e => e.RemainingSeats)</span> </td>
            </tr>
            <tr>
                <td>Your Seat</td>
                <td><span class="light">@Model.SeatName</span></td>
            </tr>
        </table>
    } 
    <table>
        @foreach (var s in @Model.Seats.OrderBy(e => e.CloseDate).Where(e=>!e.IsTardy || Request.IsAuthenticated))
        {
            <tr>
                <td><span class="light">@s.Name Seat</span> closes on <span class="light">@s.CloseDate.ToString("MMM d, yyyy")</span></td>
            </tr>
        }
    </table>
    
    @Html.Partial("_Contact")


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jquery")

    <script>
       /* $('input:submit').click(function () {
            var form = $(this).parents("form");
            form.validate();
            if (form.find('.input-validation-error').length == 0) {
                $(this).attr('hidden', 'hidden');
            }
        }); */
        /*
        $('form').bind('submit', function (e) {
            if ($(this).find('.input-validation-error').length == 0) {
                $(this).find('input:submit').attr('hidden', 'hidden');
            }
        });*/
        /*
        $(function () {
            $('form').submit(function () {
                if ($(this).valid()) {
                    $('input[type="submit"]').attr('disabled', 'disabled');
                }
            });
        });
        */
        
        /*
        $('form').submit(function () {
            $(this).validate();
            if ($(this).find('.input-validation-error').length == 0) {
                $(this).find('input:submit').attr('hidden', 'hidden');
                return true;
            }
            else return false;
        });
        */

    </script>
}
